using NUnit.Framework;

namespace generator.tests
{
    [TestFixture]
    public class StringExtensionsTests
    {
        [Test]
        public void StripRight_from_string_containing_the_string_to_strip_at_the_end() {
            Assert.That("abc".StripRight("c"), Is.EqualTo("ab"));
        }

        [Test]
        public void StripRight_from_string_containing_the_string_to_strip_but_not_at_the_end() {
            Assert.That("abc".StripRight("b"), Is.EqualTo("abc"));
        }

        [Test]
        public void SubstringAfterLast() {
            Assert.That(@"a\b\c".SubstringAfterLast(@"\"), Is.EqualTo("c"));
        }

        [Test]
        public void SubstringAfterLast_starting_with_search_string() {
            Assert.That(@"\c".SubstringAfterLast(@"\"), Is.EqualTo("c"));
        }

        [Test]
        public void Uppercase_with_only_one_char() {
            Assert.That("a".FirstLetterToUppercase(), Is.EqualTo("A"));
        }

        [Test]
        public void Uppercase_of_empty_string() {
            Assert.That("".FirstLetterToUppercase(), Is.EqualTo(""));
        }

        [Test]
        public void Uppercaseg() {
            Assert.That("abcDefg".FirstLetterToUppercase(), Is.EqualTo("AbcDefg"));
        }

        [Test]
        public void SubstringUpTo_with_search_string() {
            Assert.That("a.b".SubstringUpTo("."), Is.EqualTo("a"));
        }

        [Test]
        public void SubstringUpTo_with_multiple_occurences_of_search_string() {
            Assert.That("a.b.c".SubstringUpTo("."), Is.EqualTo("a"));
        }

        [Test]
        public void SubstringUpTo_without_search_string() {
            Assert.That("a".SubstringUpTo("."), Is.EqualTo("a"));
        }

        [Test]
        public void SubstringUpToLast_with_search_string() {
            Assert.That("a.b".SubstringUpToLast("."), Is.EqualTo("a"));
        }

        [Test]
        public void SubstringUpToLast_with_multiple_occurences_of_search_string() {
            Assert.That("a.b.c".SubstringUpToLast("."), Is.EqualTo("a.b"));
        }

        [Test]
        public void SubstringUpToLast_without_search_string() {
            Assert.That("a".SubstringUpToLast("."), Is.EqualTo("a"));
        }
    }
}